package com.example.newland.radiogroup;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;

public class MainActivity extends AppCompatActivity {

    private RadioGroup main_rg_group;
    private RadioButton main_rb_open;
    private RadioButton main_rb_close;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        main_rg_group = findViewById(R.id.main_rg_group);
        main_rb_open = findViewById(R.id.main_rb_open);
        main_rb_close = findViewById(R.id.main_rb_close);

        main_rg_group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                RadioButton rb = findViewById(i);
                if(rb.getText().toString().equals("开")){
                    Log.i("","打开了");
                }else{
                    Log.i("","关闭了");
                }

            }
        });
    }

    @Override
    protected void onStop() {
        super.onStop();
    }
}
